package com.bootlever.framework.common.model;

import com.bootlever.framework.common.constant.EnumMailType;
import com.bootlever.framework.common.utils.StringUtils;

import java.io.Serializable;
import java.util.List;

public class BaseMailEntity implements Serializable {
    private static final long serialVersionUID = -3720788526453788058L;
    private String title;
    private String content;
    private EnumMailType mailType = EnumMailType.TEXT;//默认text
    private List<String> receivers = null;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public List<String> getReceivers() {
        return receivers;
    }

    public void setReceivers(List<String> receivers) {
        this.receivers = receivers;
    }

    public boolean addReceiver(String address){
        return this.receivers.add(address);
    }

    public String removeReceiver(int index){
        return this.receivers.remove(index);
    }

    public EnumMailType getMailType() {
        return mailType;
    }

    public void setMailType(EnumMailType mailType) {
        this.mailType = mailType;
    }

    public String getContentType(){
        return this.mailType.getContentType();
    }

    /**
     * 判断是否可以发送
     * @return
     */
    public boolean isEnableSend(){
        if (StringUtils.isBlank(title)||StringUtils.isBlank(content)||mailType == null||
                receivers == null || receivers.size() == 0){
            return false;
        }
        return true;
    }
}
